package com.abel.demo.controller;

import com.abel.demo.common.BusinessException;
import com.abel.demo.common.Resp;
import com.abel.demo.common.RespCode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Author: Abel.lin
 * Date: Created in 2018/5/31 15:49
 * Company: Abel.Studio
 * Copyright: Copyright (c) 2017
 * Description:
 */
@RestController
public class IndexController {
    @GetMapping("")
    public Resp index(){
        return Resp.ok("demo word");
    }

    @GetMapping("test0")
    public Resp test0(HttpServletRequest request){
        if(request != null) {
            throw new BusinessException("自定义异常");
        }
        return Resp.ok(RespCode.Default.SUCCESS);
    }
    @GetMapping("test1")
    public Resp test1(){
        int i=0;
        int j = 3/i;
        return Resp.ok(RespCode.Default.SUCCESS);
    }
}
